//
//  StatusCell.swift
//  weibo
//
//  Created by apple on 16/2/26.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit
import SnapKit

class StatusCell: UITableViewCell {

    var bottomViewTopConstaint: Constraint?
    
    var status: Status? {
    
        didSet{
        //设置原创微博的数据模型
            
        
        }
    }
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        //完成自定义操作
        setupUI()
        
        selectionStyle = .None
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
    
        contentView.addSubview(statusCellBottomView)
        contentView.addSubview(statusOriginalView)
        contentView.addSubview(statusRetweetedView)
        //设置约束
        statusOriginalView.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(contentView.snp_left)
            make.right.equalTo(contentView.snp_right)
            make.top.equalTo(contentView.snp_top)
            //设置高度
            //            make.height.equalTo(80)
            
            //遍历约束对象查询 然后进行约束匹配  不是特别高效
            //            make.left.right.top.equalTo(contentView)
        }
        
        
        statusRetweetedView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(statusOriginalView.snp_bottom)
            make.left.equalTo(statusOriginalView.snp_left)
            make.right.equalTo(statusOriginalView.snp_right)
        }
        
        statusCellBottomView.snp_makeConstraints { (make) -> Void in
            //添加约束对象 并且记录约束对象
            self.bottomViewTopConstaint =  make.top.equalTo(statusRetweetedView.snp_bottom).constraint
            make.left.equalTo(contentView.snp_left)
            make.right.equalTo(contentView.snp_right)
            //设置高度
            make.height.equalTo(35)
        }
        
        //给contentView添加约束
        contentView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.right.equalTo(self.snp_right)
            //最关键的约束
            make.bottom.equalTo(statusCellBottomView.snp_bottom)
        }
        
    
    }
    
    //懒加载视图
    private lazy var statusOriginalView: StatusCellOriginalView = StatusCellOriginalView()
    
    //转发微博部分的视图
    private lazy var statusRetweetedView: StatusRetweetedView = StatusRetweetedView()
    
    //底部视图
    private lazy var statusCellBottomView: StatusCellBottomView = StatusCellBottomView()
    
}
